package org.github.socket.protocol.ykq.client.process;

import org.github.socket.protocol.ykq.protocol.XPacket;
import org.smartboot.socket.StateMachineEnum;
import org.smartboot.socket.extension.processor.AbstractMessageProcessor;
import org.smartboot.socket.transport.AioSession;
import org.tinylog.Logger;

/**
 * 回复电桩登陆结果
 * <p>
 * 68（起始标志）0C（数据长度）0000（序列号域）00（加密标志）02（类型）55 03 14 12 78 23
 * 05（桩编码）00（登陆结果：成功）DA 4C（帧校验域）
 */
public class LoginAuthenticationResponseProcessor extends AbstractMessageProcessor<XPacket> {


    /**
     * 处理接收到的消息
     */
    @Override
    public void process0(AioSession session, XPacket msg) {
        ClientYunKProtocolProcessorRegister.PROCESS_STRATEGY.get(msg.getSegmentTypeFlagHex()).process(session, msg);
    }


    @Override
    public void stateEvent0(AioSession session, StateMachineEnum stateMachineEnum, Throwable throwable) {
        if (throwable != null) {
            Logger.error(stateMachineEnum + " exception:", throwable);
        }
    }
}
